package cn.lanqiao.springboot.service;

import cn.lanqiao.springboot.entity.Menu;
import cn.lanqiao.springboot.mapper.MenuMapper;
import cn.lanqiao.springboot.redis.MenuRedisRepository;
import cn.lanqiao.springboot.vo.QueryMenuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuService {
    @Autowired
    MenuMapper menuMapper;

    @Autowired
    MenuRedisRepository menuRedisRepository;

    //缓存加载
    @Cacheable(value = "roleId",cacheManager = "OneDay")
    public List<Menu> getList(int roleId) {
//        List<Menu> menuList = menuRedisRepository.get(roleId);
//        if(menuList == null){
//            menuList = menuMapper.getList(roleId);
//            menuRedisRepository.save(roleId,menuList);
//        }
//        return menuList;
        return menuMapper.getList(roleId);
    }

    public List<Menu> getALLMenuList(QueryMenuVO queryMenuVO){
        return menuMapper.getALLMenuList(queryMenuVO);
    }
}
